package com.unit.jmsspring.config;

import org.springframework.context.annotation.Bean;
import org.springframework.jms.connection.SingleConnectionFactory;
import org.springframework.jms.core.JmsTemplate;

import javax.annotation.Resource;

/**
 * 生产者配置类
 * Created by hgb on 2017/08/09 21:26
 */
public class ProducerConfig {

    @Resource(name = "connectionFactory")
    private SingleConnectionFactory singleConnectionFactory;

    /**
     * 功能：配置Spring提供JmsTemplate，用于发送消息
     */
    @Bean
    public JmsTemplate jmsTemplate(){
        JmsTemplate jmsTemplate= new JmsTemplate();
        jmsTemplate.setConnectionFactory(singleConnectionFactory);
        return jmsTemplate;
    }


}
